﻿

@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@using (Html.BeginForm("AddUpdradeConfig", "Upgrade", FormMethod.Post))
{
    <h4 class="page-header">Chi tiết gói sản phẩm</h4>
    <div class="col-md-6 col-md-offset-3">
        <div class="panel panel-default">
            <div class="panel-heading panel-default">
                <h3 class="panel-title">Thêm nhóm mới</h3>
            </div>
            <div class="panel-body">
                <form role="form">
                    <fieldset>
                        <div class="form-group">
                            <label>Tầng Số</label>
                            <ul class="errorMessages"></ul>
                            <input type="text" name="Floor" class="form-control" required="" placeholder="Example 1" value="1">
                        </div>
                        <div class="form-group">
                            <label>Tên Tầng</label>
                            <ul class="errorMessages"></ul>
                            <input type="text" name="FloorName" class="form-control" required="" placeholder="Example Tầng một">
                        </div>
                        <div class="form-group">
                            <label>Hoa hồng</label>
                            <ul class="errorMessages"></ul>
                            <input type="text" name="Commission" class="form-control" required="" placeholder="Example 500000" value="0">
                        </div>
                        <div class="form-group">
                            <label>Level User</label>
                            <ul class="errorMessages"></ul>
                            <input type="text" name="UserLevel" class="form-control" required="" placeholder="Example 500000" value="0">
                        </div>
                        <button type="submit" class="btn_submit btn btn-default">Save</button>
                        <button type="reset" class="btn_submit btn btn-default">Cancel</button>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
}
<script>
    var createAllErrors = function () {
        var form = $(this),
            errorList = $("ul.errorMessages", form);

        var showAllErrorMessages = function () {
            errorList.empty();
            var invalidFields = form.find(":invalid").each(function (index, node) {
                var label = $("label[for=" + node.id + "] "),
                    message = node.validationMessage || 'Invalid value.';

                errorList
                    .show()
                    .append("<li><span>" + label.html() + "</span> " + message + "</li>");
            });
        };
        form.on("submit", function (event) {
            if (this.checkValidity && !this.checkValidity()) {
                $(this).find(":invalid").first().focus();
                event.preventDefault();
            }
        });

        $("input[type=submit], button:not([type=button])", form)
            .on("click", showAllErrorMessages);

        $("input", form).on("keypress", function (event) {
            var type = $(this).attr("type");
            if (/date|email|month|number|search|tel|text|time|url|week/.test(type)
              && event.keyCode == 13) {
                showAllErrorMessages();
            }
        });
    };

    $("form").each(createAllErrors);
</script>

